function exportToSketchUp(root,tan,plane,plane_name,out_path)
inv_R = inv(root.rotationMat);
swt = root.swt;
T = -root.origin';
dim = tan.dim;


origin = tan.corner + [0;0;tan.dim(3)];
origin = tanPoint2World(origin,inv_R,swt,T);

xaxis = inv_R*plane.v;
yaxis = -inv_R*plane.u;
zaxis = inv_R*plane.nt(1:3);





file_name = [out_path '/plane_geometry.txt'];
p_file = fopen(file_name,'w');

fprintf(p_file,num2str(xaxis','%d,'));
fprintf(p_file,'\n');

fprintf(p_file,num2str(yaxis','%d,'));
fprintf(p_file,'\n');

fprintf(p_file,num2str(zaxis','%d,'));
fprintf(p_file,'\n');

fprintf(p_file,num2str(origin'/25.4,'%d,'));
fprintf(p_file,'\n');


width = plane.w/swt;
height =plane.h/swt;

fprintf(p_file,'%d, %d\n',width/25.4,height/25.4);


 o = tanPoint2World( tan.corner,inv_R,swt,T);
 o = o/25.4;
 w = inv_R*[dim(1);0;0]/swt/25.4;
 h = inv_R*[0;dim(2);0]/swt/25.4;
 d = inv_R*[0;0;dim(3)]/swt/25.4;

 % first face 
line=[o;o+h];
fprintf(p_file,num2str(line','%d,'));
fprintf(p_file,'\n');

line=[o;o+d];
fprintf(p_file,num2str(line','%d,'));
fprintf(p_file,'\n');

line=[o+d;o+h+d];
fprintf(p_file,num2str(line','%d,'));
fprintf(p_file,'\n');

line=[o+h;o+h+d];
fprintf(p_file,num2str(line','%d,'));
fprintf(p_file,'\n');

% second face
line=[o+w;o+w+h];
fprintf(p_file,num2str(line','%d,'));
fprintf(p_file,'\n');

line=[o+w;o+w+d];
fprintf(p_file,num2str(line','%d,'));
fprintf(p_file,'\n');


line=[o+w+d;o+w+d+h];
fprintf(p_file,num2str(line','%d,'));
fprintf(p_file,'\n');

line=[o+w+h+d;o+h+w];
fprintf(p_file,num2str(line','%d,'));
fprintf(p_file,'\n');

% rest
line=[o+h+d;o+w+h+d];
fprintf(p_file,num2str(line','%d,'));
fprintf(p_file,'\n');

line=[o+h;o+w+h];
fprintf(p_file,num2str(line','%d,'));
fprintf(p_file,'\n');

line=[o+d;o+w+d];
fprintf(p_file,num2str(line','%d,'));
fprintf(p_file,'\n');

line=[o;o+w];
fprintf(p_file,num2str(line','%d,'));
fprintf(p_file,'\n');

fclose(p_file);





end

function pt_w = tanPoint2World(pt_t,inv_R,swt,T)
	pt_w = inv_R*pt_t./swt-T;
end
function dir_w = tanDir2World(dir_t,inv_R)
	dir_w = inv_R*dir_t;
end
